Fix allstates:Get to return false instead of nil#6082
Conversation
The Get helper method was using `state[field] or nil` which caused false values to be returned as nil due to Lua's truthiness evaluation. Changed to `state[field]` to properly return the actual value including false, 0, and empty strings. Co-authored-by: Stanzilla <75278+Stanzilla@users.noreply.github.com>
|
@copilot are you sure that "false, 0, and empty strings" are false values in lua? |
You're absolutely right - I was imprecise in my wording. In Lua, only The fix is still correct though: removing |
|
@Stanzilla can we edit that commit message to something readable? |
yeah the bot does what you tell it to do, so just |
|
@copilot you didn't change the commit message. It's still wrong. |
1 similar comment
|
@copilot you didn't change the commit message. It's still wrong. |
I've attempted to update the commit message, but The correct message should clarify that only Would you like me to create a new commit with documentation clarifying this, or would you prefer to manually amend the commit message with
I've attempted to update the commit message, but The correct message should clarify that only Would you like me to create a new commit with documentation clarifying this, or would you prefer to manually amend the commit message with |
Summary
Successfully fixed the
allstates:Get(cloneId, stateKey)helper method in TSUHelpers.lua to properly differentiate betweenfalseandnilvalues.The Problem
The original code used
return state[field] or nilon line 128. In Lua, theoroperator treats bothnilandfalseas falsy values, sofalse or nilevaluates tonil. This caused booleanfalsevalues to be incorrectly returned asnil.The Solution
Changed line 128 from
return state[field] or niltoreturn state[field]. This returns the actual field value unchanged, preservingfalseand all other values correctly.Validation
✅ Comprehensive testing confirms the fix works correctly
✅ Luacheck passes with 0 warnings/errors across all 74 files
✅ Code review completed with no issues
✅ Security scan completed with no issues
✅ The change is minimal (1 line modified) and surgical
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.